<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - test/impl/unit_test_main.ipp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/impl</a> - unit_test_main.ipp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">70</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">8.6 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">6</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2001-2008.
<span class="lineNum">       2 </span>                : //  Distributed under the Boost Software License, Version 1.0.
<span class="lineNum">       3 </span>                : //  (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : main function implementation for Unit Test Framework
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/framework.hpp&gt;
<span class="lineNum">      20 </span>                : #include &lt;boost/test/results_collector.hpp&gt;
<span class="lineNum">      21 </span>                : #include &lt;boost/test/unit_test_suite_impl.hpp&gt;
<span class="lineNum">      22 </span>                : #include &lt;boost/test/results_reporter.hpp&gt;
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span>                : #include &lt;boost/test/detail/unit_test_parameters.hpp&gt;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : #if !defined(__BORLANDC__) &amp;&amp; !BOOST_WORKAROUND( BOOST_MSVC, &lt; 1300 )
<span class="lineNum">      27 </span>                : #include &lt;boost/test/utils/iterator/token_iterator.hpp&gt;
<span class="lineNum">      28 </span>                : #endif
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : // Boost
<span class="lineNum">      31 </span>                : #include &lt;boost/cstdlib.hpp&gt;
<span class="lineNum">      32 </span>                : #include &lt;boost/bind.hpp&gt;
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                : // STL
<span class="lineNum">      35 </span>                : #include &lt;stdexcept&gt;
<span class="lineNum">      36 </span>                : #include &lt;iostream&gt;
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : //____________________________________________________________________________//
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                : namespace boost {
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span>                : namespace unit_test {
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span>                : // ************************************************************************** //
<span class="lineNum">      47 </span>                : // **************                 test_case_filter             ************** //
<span class="lineNum">      48 </span>                : // ************************************************************************** //
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span><span class="lineNoCov">              0 : class test_case_filter : public test_tree_visitor {</span>
<span class="lineNum">      51 </span>                : public:
<span class="lineNum">      52 </span><span class="lineNoCov">              0 :     struct single_filter {</span>
<span class="lineNum">      53 </span><span class="lineNoCov">              0 :         single_filter( const_string in )</span>
<span class="lineNum">      54 </span><span class="lineNoCov">              0 :         {</span>
<span class="lineNum">      55 </span><span class="lineNoCov">              0 :             if( in == &quot;*&quot; )</span>
<span class="lineNum">      56 </span><span class="lineNoCov">              0 :                 m_kind  = SFK_ALL;</span>
<span class="lineNum">      57 </span><span class="lineNoCov">              0 :             else if( first_char( in ) == '*' &amp;&amp; last_char( in ) == '*' ) {</span>
<span class="lineNum">      58 </span><span class="lineNoCov">              0 :                 m_kind  = SFK_SUBSTR;</span>
<span class="lineNum">      59 </span><span class="lineNoCov">              0 :                 m_value = in.substr( 1, in.size()-1 );</span>
<span class="lineNum">      60 </span>                :             }
<span class="lineNum">      61 </span><span class="lineNoCov">              0 :             else if( first_char( in ) == '*' ) {</span>
<span class="lineNum">      62 </span><span class="lineNoCov">              0 :                 m_kind  = SFK_TRAILING;</span>
<span class="lineNum">      63 </span><span class="lineNoCov">              0 :                 m_value = in.substr( 1 );</span>
<span class="lineNum">      64 </span>                :             }
<span class="lineNum">      65 </span><span class="lineNoCov">              0 :             else if( last_char( in ) == '*' ) {</span>
<span class="lineNum">      66 </span><span class="lineNoCov">              0 :                 m_kind  = SFK_LEADING;</span>
<span class="lineNum">      67 </span><span class="lineNoCov">              0 :                 m_value = in.substr( 0, in.size()-1 );</span>
<span class="lineNum">      68 </span>                :             }
<span class="lineNum">      69 </span>                :             else {
<span class="lineNum">      70 </span><span class="lineNoCov">              0 :                 m_kind  = SFK_MATCH;</span>
<span class="lineNum">      71 </span><span class="lineNoCov">              0 :                 m_value = in;</span>
<span class="lineNum">      72 </span>                :             }
<span class="lineNum">      73 </span><span class="lineNoCov">              0 :         };</span>
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span><span class="lineNoCov">              0 :         bool            pass( test_unit const&amp; tu ) const</span>
<span class="lineNum">      76 </span>                :         {
<span class="lineNum">      77 </span><span class="lineNoCov">              0 :             const_string name( tu.p_name );</span>
<span class="lineNum">      78 </span>                :     
<span class="lineNum">      79 </span><span class="lineNoCov">              0 :             switch( m_kind ) {</span>
<span class="lineNum">      80 </span>                :             default:
<span class="lineNum">      81 </span>                :             case SFK_ALL:
<span class="lineNum">      82 </span><span class="lineNoCov">              0 :                 return true;</span>
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span>                :             case SFK_LEADING:
<span class="lineNum">      85 </span><span class="lineNoCov">              0 :                 return name.substr( 0, m_value.size() ) == m_value;</span>
<span class="lineNum">      86 </span>                : 
<span class="lineNum">      87 </span>                :             case SFK_TRAILING:
<span class="lineNum">      88 </span><span class="lineNoCov">              0 :                 return name.size() &gt;= m_value.size() &amp;&amp; name.substr( name.size() - m_value.size() ) == m_value;</span>
<span class="lineNum">      89 </span>                : 
<span class="lineNum">      90 </span>                :             case SFK_SUBSTR:
<span class="lineNum">      91 </span><span class="lineNoCov">              0 :                 return name.find( m_value ) != const_string::npos;</span>
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span>                :             case SFK_MATCH:
<span class="lineNum">      94 </span><span class="lineNoCov">              0 :                 return m_value == tu.p_name.get();</span>
<span class="lineNum">      95 </span>                :             }
<span class="lineNum">      96 </span>                :         }
<span class="lineNum">      97 </span>                :         enum kind { SFK_ALL, SFK_LEADING, SFK_TRAILING, SFK_SUBSTR, SFK_MATCH };
<span class="lineNum">      98 </span>                : 
<span class="lineNum">      99 </span>                :         kind            m_kind;
<span class="lineNum">     100 </span>                :         const_string    m_value;
<span class="lineNum">     101 </span>                :     };
<span class="lineNum">     102 </span>                :     // Constructor
<span class="lineNum">     103 </span>                : #if defined(__BORLANDC__) || BOOST_WORKAROUND( BOOST_MSVC, &lt; 1300 )
<span class="lineNum">     104 </span>                :     explicit        test_case_filter( const_string ) : m_depth( 0 ) {}
<span class="lineNum">     105 </span>                : #else
<span class="lineNum">     106 </span><span class="lineNoCov">              0 :     explicit        test_case_filter( const_string tc_to_tun ) </span>
<span class="lineNum">     107 </span><span class="lineNoCov">              0 :     : m_depth( 0 )</span>
<span class="lineNum">     108 </span>                :     {
<span class="lineNum">     109 </span><span class="lineNoCov">              0 :         string_token_iterator tit( tc_to_tun, (dropped_delimeters = &quot;/&quot;, kept_delimeters = dt_none) );</span>
<span class="lineNum">     110 </span>                : 
<span class="lineNum">     111 </span><span class="lineNoCov">              0 :         while( tit != string_token_iterator() ) {</span>
<span class="lineNum">     112 </span>                :             m_filters.push_back( 
<span class="lineNum">     113 </span>                :                 std::vector&lt;single_filter&gt;( string_token_iterator( *tit, (dropped_delimeters = &quot;,&quot;, kept_delimeters = dt_none)  ), 
<span class="lineNum">     114 </span><span class="lineNoCov">              0 :                                             string_token_iterator() ) );</span>
<span class="lineNum">     115 </span>                : 
<span class="lineNum">     116 </span><span class="lineNoCov">              0 :             ++tit;           </span>
<span class="lineNum">     117 </span>                :         }
<span class="lineNum">     118 </span><span class="lineNoCov">              0 :     }</span>
<span class="lineNum">     119 </span>                : #endif
<span class="lineNum">     120 </span>                :     
<span class="lineNum">     121 </span><span class="lineNoCov">              0 :     void            filter_unit( test_unit const&amp; tu )</span>
<span class="lineNum">     122 </span>                :     {
<span class="lineNum">     123 </span><span class="lineNoCov">              0 :         if( (++m_depth - 1) &gt; m_filters.size() ) {</span>
<span class="lineNum">     124 </span><span class="lineNoCov">              0 :             tu.p_enabled.value = true;</span>
<span class="lineNum">     125 </span><span class="lineNoCov">              0 :             return;</span>
<span class="lineNum">     126 </span>                :         }
<span class="lineNum">     127 </span>                : 
<span class="lineNum">     128 </span><span class="lineNoCov">              0 :         if( m_depth == 1 )</span>
<span class="lineNum">     129 </span><span class="lineNoCov">              0 :             return;</span>
<span class="lineNum">     130 </span>                : 
<span class="lineNum">     131 </span><span class="lineNoCov">              0 :         std::vector&lt;single_filter&gt; const&amp; filters = m_filters[m_depth-2];</span>
<span class="lineNum">     132 </span>                : 
<span class="lineNum">     133 </span>                :         tu.p_enabled.value =
<span class="lineNum">     134 </span><span class="lineNoCov">              0 :             std::find_if( filters.begin(), filters.end(), bind( &amp;single_filter::pass, _1, boost::ref(tu) ) ) != filters.end();</span>
<span class="lineNum">     135 </span>                :     }
<span class="lineNum">     136 </span>                : 
<span class="lineNum">     137 </span>                :     // test tree visitor interface
<span class="lineNum">     138 </span><span class="lineNoCov">              0 :     virtual void    visit( test_case const&amp; tc )</span>
<span class="lineNum">     139 </span>                :     {
<span class="lineNum">     140 </span><span class="lineNoCov">              0 :         if( m_depth &lt; m_filters.size() ) {</span>
<span class="lineNum">     141 </span><span class="lineNoCov">              0 :             tc.p_enabled.value = false;</span>
<span class="lineNum">     142 </span><span class="lineNoCov">              0 :             return;</span>
<span class="lineNum">     143 </span>                :         }
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span><span class="lineNoCov">              0 :         filter_unit( tc );</span>
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span><span class="lineNoCov">              0 :         --m_depth;</span>
<span class="lineNum">     148 </span>                :     }
<span class="lineNum">     149 </span>                : 
<span class="lineNum">     150 </span><span class="lineNoCov">              0 :     virtual bool    test_suite_start( test_suite const&amp; ts )</span>
<span class="lineNum">     151 </span>                :     { 
<span class="lineNum">     152 </span><span class="lineNoCov">              0 :         filter_unit( ts );</span>
<span class="lineNum">     153 </span>                : 
<span class="lineNum">     154 </span><span class="lineNoCov">              0 :         if( !ts.p_enabled )</span>
<span class="lineNum">     155 </span><span class="lineNoCov">              0 :             --m_depth;</span>
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span><span class="lineNoCov">              0 :         return ts.p_enabled;</span>
<span class="lineNum">     158 </span>                :     }
<span class="lineNum">     159 </span>                : 
<span class="lineNum">     160 </span><span class="lineNoCov">              0 :     virtual void    test_suite_finish( test_suite const&amp; )  { --m_depth; }</span>
<span class="lineNum">     161 </span>                : 
<span class="lineNum">     162 </span>                : private:
<span class="lineNum">     163 </span>                :     // Data members
<span class="lineNum">     164 </span>                :     std::vector&lt;std::vector&lt;single_filter&gt; &gt;    m_filters;
<span class="lineNum">     165 </span>                :     unsigned                                    m_depth;
<span class="lineNum">     166 </span>                : };
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                : // ************************************************************************** //
<span class="lineNum">     169 </span>                : // **************                  unit_test_main              ************** //
<span class="lineNum">     170 </span>                : // ************************************************************************** //
<span class="lineNum">     171 </span>                : 
<span class="lineNum">     172 </span>                : int BOOST_TEST_DECL
<span class="lineNum">     173 </span><span class="lineCov">              2 : unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )</span>
<span class="lineNum">     174 </span>                : {
<span class="lineNum">     175 </span>                :     try {
<span class="lineNum">     176 </span><span class="lineCov">              2 :         framework::init( init_func, argc, argv );</span>
<span class="lineNum">     177 </span>                : 
<span class="lineNum">     178 </span><span class="lineCov">              2 :         if( !runtime_config::test_to_run().is_empty() ) {</span>
<span class="lineNum">     179 </span><span class="lineNoCov">              0 :             test_case_filter filter( runtime_config::test_to_run() );</span>
<span class="lineNum">     180 </span>                : 
<span class="lineNum">     181 </span><span class="lineNoCov">              0 :             traverse_test_tree( framework::master_test_suite().p_id, filter );</span>
<span class="lineNum">     182 </span>                :         }
<span class="lineNum">     183 </span>                : 
<span class="lineNum">     184 </span><span class="lineCov">              2 :         framework::run();</span>
<span class="lineNum">     185 </span>                : 
<span class="lineNum">     186 </span><span class="lineCov">              2 :         results_reporter::make_report();</span>
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                :         return runtime_config::no_result_code() 
<span class="lineNum">     189 </span>                :                     ? boost::exit_success 
<span class="lineNum">     190 </span><span class="lineCov">              2 :                     : results_collector.results( framework::master_test_suite().p_id ).result_code();</span>
<span class="lineNum">     191 </span>                :     }
<span class="lineNum">     192 </span><span class="lineNoCov">              0 :     catch( framework::internal_error const&amp; ex ) {</span>
<span class="lineNum">     193 </span><span class="lineNoCov">              0 :         results_reporter::get_stream() &lt;&lt; &quot;Boost.Test framework internal error: &quot; &lt;&lt; ex.what() &lt;&lt; std::endl;</span>
<span class="lineNum">     194 </span>                :         
<span class="lineNum">     195 </span><span class="lineNoCov">              0 :         return boost::exit_exception_failure;</span>
<span class="lineNum">     196 </span>                :     }
<span class="lineNum">     197 </span><span class="lineNoCov">              0 :     catch( framework::setup_error const&amp; ex ) {</span>
<span class="lineNum">     198 </span><span class="lineNoCov">              0 :         results_reporter::get_stream() &lt;&lt; &quot;Test setup error: &quot; &lt;&lt; ex.what() &lt;&lt; std::endl;</span>
<span class="lineNum">     199 </span>                :         
<span class="lineNum">     200 </span><span class="lineNoCov">              0 :         return boost::exit_exception_failure;</span>
<span class="lineNum">     201 </span>                :     }
<span class="lineNum">     202 </span><span class="lineNoCov">              0 :     catch( ... ) {</span>
<span class="lineNum">     203 </span><span class="lineNoCov">              0 :         results_reporter::get_stream() &lt;&lt; &quot;Boost.Test framework internal error: unknown reason&quot; &lt;&lt; std::endl;</span>
<span class="lineNum">     204 </span>                :         
<span class="lineNum">     205 </span><span class="lineNoCov">              0 :         return boost::exit_exception_failure;</span>
<span class="lineNum">     206 </span>                :     }
<span class="lineNum">     207 </span>                : }
<span class="lineNum">     208 </span>                : 
<span class="lineNum">     209 </span>                : } // namespace unit_test
<span class="lineNum">     210 </span>                : 
<span class="lineNum">     211 </span>                : } // namespace boost
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span>                : #if !defined(BOOST_TEST_DYN_LINK) &amp;&amp; !defined(BOOST_TEST_NO_MAIN)
<span class="lineNum">     214 </span>                : 
<span class="lineNum">     215 </span>                : // ************************************************************************** //
<span class="lineNum">     216 </span>                : // **************        main function for tests using lib     ************** //
<span class="lineNum">     217 </span>                : // ************************************************************************** //
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span>                : int BOOST_TEST_CALL_DECL
<span class="lineNum">     220 </span>                : main( int argc, char* argv[] )
<span class="lineNum">     221 </span>                : {
<span class="lineNum">     222 </span>                :     // prototype for user's unit test init function
<span class="lineNum">     223 </span>                : #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
<span class="lineNum">     224 </span>                :     extern bool init_unit_test();
<span class="lineNum">     225 </span>                : 
<span class="lineNum">     226 </span>                :     boost::unit_test::init_unit_test_func init_func = &amp;init_unit_test;
<span class="lineNum">     227 </span>                : #else
<span class="lineNum">     228 </span>                :     extern ::boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] );
<span class="lineNum">     229 </span>                : 
<span class="lineNum">     230 </span>                :     boost::unit_test::init_unit_test_func init_func = &amp;init_unit_test_suite;
<span class="lineNum">     231 </span>                : #endif
<span class="lineNum">     232 </span>                : 
<span class="lineNum">     233 </span>                :     return ::boost::unit_test::unit_test_main( init_func, argc, argv );
<span class="lineNum">     234 </span>                : }
<span class="lineNum">     235 </span>                : 
<span class="lineNum">     236 </span>                : #endif // !BOOST_TEST_DYN_LINK &amp;&amp; !BOOST_TEST_NO_MAIN
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : //____________________________________________________________________________//
<span class="lineNum">     239 </span>                : 
<span class="lineNum">     240 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     241 </span>                : 
<span class="lineNum">     242 </span>                : #endif // BOOST_TEST_UNIT_TEST_MAIN_IPP_012205GER
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
